package cn.kgc.mes.storage.service.impl;

import java.util.List;
import cn.kgc.mes.common.utils.DateUtils;
import cn.kgc.mes.storage.domain.StorageArea;
import cn.kgc.mes.storage.domain.StorageLocation;
import cn.kgc.mes.storage.domain.Warehouse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.kgc.mes.storage.mapper.RtIssueMapper;
import cn.kgc.mes.storage.domain.RtIssue;
import cn.kgc.mes.storage.service.IRtIssueService;

/**
 * 生产退料Service业务层处理
 * 
 * @author ydw
 * @date 2025-09-15
 */
@Service
public class RtIssueServiceImpl implements IRtIssueService 
{
    @Autowired
    private RtIssueMapper rtIssueMapper;

    /**
     * 查询生产退料
     * 
     * @param rtId 生产退料主键
     * @return 生产退料
     */
    @Override
    public RtIssue selectRtIssueByRtId(Long rtId)
    {
        return rtIssueMapper.selectRtIssueByRtId(rtId);
    }

    /**
     * 查询生产退料列表
     * 
     * @param rtIssue 生产退料
     * @return 生产退料
     */
    @Override
    public List<RtIssue> selectRtIssueList(RtIssue rtIssue)
    {
        return rtIssueMapper.selectRtIssueList(rtIssue);
    }

    /**
     * 新增生产退料
     * 
     * @param rtIssue 生产退料
     * @return 结果
     */
    @Override
    public int insertRtIssue(RtIssue rtIssue)
    {
        rtIssue.setCreateTime(DateUtils.getNowDate());
        return rtIssueMapper.insertRtIssue(rtIssue);
    }

    /**
     * 修改生产退料
     * 
     * @param rtIssue 生产退料
     * @return 结果
     */
    @Override
    public int updateRtIssue(RtIssue rtIssue)
    {
        rtIssue.setUpdateTime(DateUtils.getNowDate());
        return rtIssueMapper.updateRtIssue(rtIssue);
    }

    /**
     * 批量删除生产退料
     * 
     * @param rtIds 需要删除的生产退料主键
     * @return 结果
     */
    @Override
    public int deleteRtIssueByRtIds(Long[] rtIds)
    {
        return rtIssueMapper.deleteRtIssueByRtIds(rtIds);
    }

    /**
     * 删除生产退料信息
     * 
     * @param rtId 生产退料主键
     * @return 结果
     */
    @Override
    public int deleteRtIssueByRtId(Long rtId)
    {
        return rtIssueMapper.deleteRtIssueByRtId(rtId);
    }
    //    仓库联查
    public List<RtIssue> selectRtIssueList1(){
        return rtIssueMapper.selectRtIssueList1();
    }
    //根据id查询仓库数据
    public Warehouse WarehouseById(Long id){
        return rtIssueMapper.WarehouseById(id);
    }
    //根据id查询库区数据
    public StorageLocation StorageLocationById(Long id){
        return rtIssueMapper.StorageLocationById(id);
    }
    //根据id查询库位数据
    public StorageArea StorageAreaById(Long id){
        return rtIssueMapper.StorageAreaById(id);
    }
}
